# 编写一个Python程序： -
# 1.房子有户型，总面积和家具名称列表，新房子没有任何的家具。 -
# 2.家具有名字和占地面积，其中 - 床：占4平米 - 衣柜：占2平米 - 餐桌：占1.5平米 -
# 3.将以上三件家具添加到房子中 -
# 4.打印房子时，要求输出:户型，总面积，剩余面积，家具名称列表


class House:
    def __init__(self, Htype, Harea):
        self.Htype = Htype
        self.Harea = Harea
        self.furniture = []
        self.Sarea = self.Harea

    def __str__(self):
        return f"户型是{self.Htype},面积是{self.Harea}"

    def add_furniture(self, furniture):
        self.furniture.append(furniture)
        self.Sarea -= furniture.area

    def dispiay(self):
        print(f"房子的户型是{self.Htype}")
        print(f"总面积是{self.Harea}")
        print(f"剩余面积是{self.Sarea}")
        print("家具有")
        for i in self.furniture:
            print(i.furniture_name)


class Furniture:
    def __init__(self, furniture_name, area):
        self.furniture_name = furniture_name
        self.area = area


if __name__ == '__main__':
    h1 = House("四房一厅", 100)
    bed = Furniture("床", 4)
    wardrobe = Furniture("衣柜", 2)
    table = Furniture("餐桌", 1.5)

    h1.add_furniture(bed)
    h1.add_furniture(wardrobe)
    h1.add_furniture(table)

    h1.dispiay()
